From 5fcd668a025564a60cab4429c641f56e8361dbdb Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Mon, 20 Jun 2011 12:09:22 +0000 Subject: [PATCH] Followup r90429: * Reverted the public -> protected changes from r90429, except for doQuery() after a review of usage: ** resultObject() is used by lots of things in core and extensions. ** makeSelectOptions() is used by SMW, and if that's going to be public, the other two probably should be too, for consistency. ** doQuery() was used by several things, but mostly by mistake. It's been marked private since r21359 which is before almost all of them. I updated the callers to use query(). * Added "protected" to doQuery() declarations in other database classes. --- includes/db/Database.php | 17 +++++++++++------ includes/db/DatabaseIbm_db2.php | 4 +--- includes/db/DatabaseMssql.php | 2 +- includes/db/DatabaseMysql.php | 2 +- includes/db/DatabaseOracle.php | 2 +- includes/db/DatabasePostgres.php | 2 +- includes/db/DatabaseSqlite.php | 2 +- 7 files changed, 17 insertions(+), 14 deletions(-) diff --git a/includes/db/Database.php b/includes/db/Database.php index eec3ddfba9..00fdcadd38 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -1044,7 +1044,7 @@ abstract class DatabaseBase implements DatabaseType { * @return Array * @see DatabaseBase::select() */ - protected function makeSelectOptions( $options ) { + function makeSelectOptions( $options ) { $preLimitTail = $postLimitTail = ''; $startOpts = ''; @@ -1517,7 +1517,7 @@ abstract class DatabaseBase implements DatabaseType { * @param $options array * @return string */ - protected function makeInsertOptions( $options ) { + function makeInsertOptions( $options ) { return implode( ' ', $options ); } @@ -1602,7 +1602,7 @@ abstract class DatabaseBase implements DatabaseType { * @param $options Array: The options passed to DatabaseBase::update * @return string */ - protected function makeUpdateOptions( $options ) { + function makeUpdateOptions( $options ) { if ( !is_array( $options ) ) { $options = array( $options ); } @@ -2758,10 +2758,15 @@ abstract class DatabaseBase implements DatabaseType { /** * Take the result from a query, and wrap it in a ResultWrapper if * necessary. Boolean values are passed through as is, to indicate success - * of write queries or failure. ResultWrapper objects are also passed - * through. + * of write queries or failure. + * + * Once upon a time, DatabaseBase::query() returned a bare MySQL result + * resource, and it was necessary to call this function to convert it to + * a wrapper. Nowadays, raw database objects are never exposed to external + * callers, so this is unnecessary in external code. For compatibility with + * old code, ResultWrapper objects are passed through unaltered. */ - protected function resultObject( $result ) { + function resultObject( $result ) { if ( empty( $result ) ) { return false; } elseif ( $result instanceof ResultWrapper ) { diff --git a/includes/db/DatabaseIbm_db2.php b/includes/db/DatabaseIbm_db2.php index d94e625156..77d8d76803 100644 --- a/includes/db/DatabaseIbm_db2.php +++ b/includes/db/DatabaseIbm_db2.php @@ -453,10 +453,8 @@ class DatabaseIbm_db2 extends DatabaseBase { * The DBMS-dependent part of query() * @param $sql String: SQL query. * @return object Result object for fetch functions or false on failure - * @access private */ - /*private*/ - public function doQuery( $sql ) { + protected function doQuery( $sql ) { $this->applySchema(); // Needed to handle any UTF-8 encoding issues in the raw sql diff --git a/includes/db/DatabaseMssql.php b/includes/db/DatabaseMssql.php index 077bd36887..5cb14fb812 100644 --- a/includes/db/DatabaseMssql.php +++ b/includes/db/DatabaseMssql.php @@ -117,7 +117,7 @@ class DatabaseMssql extends DatabaseBase { } } - function doQuery( $sql ) { + protected function doQuery( $sql ) { wfDebug( "SQL: [$sql]\n" ); $this->offset = 0; diff --git a/includes/db/DatabaseMysql.php b/includes/db/DatabaseMysql.php index 2dc3b7364a..4f46a3ff90 100644 --- a/includes/db/DatabaseMysql.php +++ b/includes/db/DatabaseMysql.php @@ -18,7 +18,7 @@ class DatabaseMysql extends DatabaseBase { return 'mysql'; } - /*private*/ function doQuery( $sql ) { + protected function doQuery( $sql ) { if( $this->bufferResults() ) { $ret = mysql_query( $sql, $this->mConn ); } else { diff --git a/includes/db/DatabaseOracle.php b/includes/db/DatabaseOracle.php index d140a11916..e3a18234b2 100644 --- a/includes/db/DatabaseOracle.php +++ b/includes/db/DatabaseOracle.php @@ -302,7 +302,7 @@ class DatabaseOracle extends DatabaseBase { return $this->mTrxLevel ? OCI_NO_AUTO_COMMIT : OCI_COMMIT_ON_SUCCESS; } - function doQuery( $sql ) { + protected function doQuery( $sql ) { wfDebug( "SQL: [$sql]\n" ); if ( !mb_check_encoding( $sql ) ) { throw new MWException( "SQL encoding is invalid\n$sql" ); diff --git a/includes/db/DatabasePostgres.php b/includes/db/DatabasePostgres.php index 3b54cce261..adc12de4e0 100644 --- a/includes/db/DatabasePostgres.php +++ b/includes/db/DatabasePostgres.php @@ -246,7 +246,7 @@ class DatabasePostgres extends DatabaseBase { } } - function doQuery( $sql ) { + protected function doQuery( $sql ) { if ( function_exists( 'mb_convert_encoding' ) ) { $sql = mb_convert_encoding( $sql, 'UTF-8' ); } diff --git a/includes/db/DatabaseSqlite.php b/includes/db/DatabaseSqlite.php index a6bc696e57..599e80af01 100644 --- a/includes/db/DatabaseSqlite.php +++ b/includes/db/DatabaseSqlite.php @@ -213,7 +213,7 @@ class DatabaseSqlite extends DatabaseBase { * * @return ResultWrapper */ - function doQuery( $sql ) { + protected function doQuery( $sql ) { $res = $this->mConn->query( $sql ); if ( $res === false ) { return false; -- 2.20.1